Expose   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 34
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 5

3 Functions

Rating   Name   Duplication   Size   Complexity  
A isInstalled 0 3 1
A install 0 13 2
A uninstall 0 13 2
1
import execa from 'execa'
2
import {error, info, success, warning} from '../utils/console'
3
import Tool from './tool'
4
5
class Expose extends Tool {
6
    alias = 'expose'
7
    name = 'Beyondcode Expose'
8
9
    /**
10
     * Install the app.
11
     */
12
    install = async (): Promise<boolean> => {
13
        if (await this.isInstalled()) {
14
            warning(`${this.name} already is installed. Execute it by running ${this.alias}`)
15
            return false
16
        }
17
18
        info(`Installing ${this.name} using Composer...`)
19
20
        await execa('composer', ['global', 'require', 'beyondcode/expose'])
21
22
        success(`Successfully installed ${this.name}.`)
23
24
        return true
25
    }
26
27
28
    /**
29
     * Uninstall the app.
30
     */
31
    uninstall = async (): Promise<boolean> => {
32
        if (!(await this.isInstalled())) {
33
            error(`${this.name} is not installed.`)
34
            return false
35
        }
36
37
        info(`Uninstalling ${this.name} using Composer...`)
38
39
        await execa('composer', ['global', 'remove', 'beyondcode/expose'])
40
41
        success(`Successfully uninstalled ${this.name}.`)
42
43
        return true
44
    }
45
46
    /**
47
     * Check if the app is already installed..
48
     */
49
    isInstalled = async (): Promise<boolean> => {
50
        const {stdout} = await execa('composer', ['global', 'show', '-i'])
51
        return stdout.includes('beyondcode/expose')
52
    }
53
}
54
55
export default Expose